package internetware.androidclient;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Device extends Activity{
	private String pfile = "internetwareclientsetting";
	private String username;
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.device);
		Intent i =getIntent();
		username = i.getStringExtra("user");
		Button b1 = (Button) findViewById(R.id.set_actual_ford);
		b1.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				EditText e1 = (EditText) findViewById(R.id.device_id);
				
				String id = e1.getText().toString();
				SharedPreferences sp = getSharedPreferences(pfile,0);
				String list = sp.getString("list", null);
				if(list!=null)
				{
					list = list +":"+username;
				}
				else
				{
					list = username;
				}
				Editor e = sp.edit();
				e.putString("list", list);
				e.putString(username, id);
				e.commit();
				finish();
			}		
		});
		Button b2= (Button)findViewById(R.id.cancel_ford);
		b2.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				finish();
			}			
		});
	}
}
